import optparse,socketserver
from core import server
from conf import settings

class ArgvHandler():
    def __init__(self):
        self.op = optparse.OptionParser()
        options,args = self.op.parse_args()

        self.verify_args(options,args)

    def verify_args(self,options,args):

        cmd = args[0]

        if hasattr(self,cmd):
            func = getattr(self,cmd)
            func()

    def start(self):

        s =socketserver.ThreadingTCPServer((settings.IP,settings.PORT),server.ServerHandler)
        s.serve_forever()

